<%include pub/admin_head.html%>
    </head>
    <body>
        <!-- Page Container -->
        <div class="page-container">
            <%include pub/admin_nav.html%>
            <!-- Page Content -->
            <div class="page-content">
                <div class="page-inner">
                	<div class="page-title">
                        <h3 class="breadcrumb-header">所有学生列表</h3>
                        <input type="hidden" value="<%= pagecount%>" id="compagecount">
                        <input type="hidden" value="<%= compageid%>" id="compageid">
                        <%if(active == 'stulist'){%>
                        <button type="button" class="btn btn-success" data-toggle="modal" data-target="#searchUserNovipModal">搜索非会员用户</button>
                        <%}else{%>
                        <button type="button" class="btn btn-success" data-toggle="modal" data-target="#searchUserVipModal">搜索会员用户</button>
                        <%}%>
                    </div>
                    <div id="main-wrapper">
                        <div class="col-md-12">
                            <table class="table" style="margin-top: 10px;">
                                <thead>
                                    <tr>
                                    	<th>序号</th>
                                        <th>帐号</th>
                                        <th>账号昵称</th>
                                        <th>所在学校</th>
										<th>所在班级</th>
                                        <th>注册时间</th>
										<th>备注信息</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                   <%for(let i = 0; i < stulist.length; i++){%>
								<tr>
									<td class="order"><%= i+1 %></td>
									<td><%= stulist[i].username %></td>
                                    <td><%= stulist[i].nickname %></td>
                                    <td>
                                        <%if(stulist[i].school){%>
                                            <%= stulist[i].school.names %>
                                        <%}%>
                                    </td>
									<td class="tab_classlist">
                                        <% var klass = stulist[i].classlist; for(let ii=0; ii < klass.length; ii++){ %>
                                            <%if(klass[ii].klassid){%>
                                            <span class="spanclass" cid="<%= klass[ii].klassid._id %>"><%= klass[ii].klassid.classname %></span>
                                            <%}else{%>
                                            <span class="spanclass">暂无班级</span>
                                            <%}%>
                                        <%}%>   
                                    </td>
                                    <td><%= stulist[i].time %></td>
									<td><%= stulist[i].remark %></td>
                                    <td>
                                        <%if(!stulist[i].school){%>
                                        <a href="javascript:;" class="btn btn-primary user_set_school" uid="<%= stulist[i]._id %>">设置学校</a>
                                        <%}%>
                                        <%if(stulist[i].status == 3){%>
                                        <a href="javascript:;" class="btn btn-success user_vip_remove" uid="<%= stulist[i]._id %>">取消会员</a>
                                        <%}else{%>
                                        <a href="javascript:;" class="btn btn-success user_vip" uid="<%= stulist[i]._id %>">设为会员</a>
                                        <%}%>
                                        <a href="javascript:;" class="btn btn-danger user_be_tch" uid="<%= stulist[i]._id %>">设为教师</a>
                                        <a href="javascript:;" class="btn btn-default user_fenhao" uid="<%= stulist[i]._id %>">封号</a>
                                    </td>
								</tr>
								<%}%>	
                                </tbody>
                            </table>
                        </div>
                        <div id="work-pagination" class="pager row"></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade bs-example-modal-sm" id="searchUserNovipModal" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">搜索非会员用户</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label>请输入用户账号</label>
                            <input type="text" class="form-control" id="user-username-novip"/>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-success search_userid_novip">搜索</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade bs-example-modal-sm" id="searchUserVipModal" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">搜索非会员用户</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label>请输入用户账号</label>
                            <input type="text" class="form-control" id="user-username-vip"/>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-success search_userid_vip">搜索</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade bs-example-modal-sm" id="changeSchoolTchModal" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">设置所在学校 <br>(修改后请通知用户重新登录账号)</h4>
                    </div>
                    <div class="modal-body">
                        <%if(school.length > 0){%>
                        <div class="form-group">
                            <label>请先选择学校</label>
                            <select class="form-control" id="school-tch">
                                <%for(let i = 0; i < school.length; i++){%>
                                <option value="<%= school[i]._id%>"><%= school[i].names%></option>
                                <%}%>
                            </select>
                        </div>
                        <%}else{%>
                        请先添加学校，<a href="/admin/schoollist" style="text-decoration: underline;">前往添加</a>
                        <%}%>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-success tch_changeschool">确认</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade bs-example-modal-sm" id="changeStuTchModal" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">将学生设置为老师 <br><span style="color:red">此过程不可逆，请谨慎操作!</span> <br>(修改后请通知用户重新登录账号)</h4>
                    </div>
                    <div class="modal-body">
                        <%if(school.length > 0){%>
                        <div class="form-group">
                            <label>请先选择学校</label>
                            <select class="form-control" id="school-stu-tch">
                                <%for(let i = 0; i < school.length; i++){%>
                                <option value="<%= school[i]._id%>"><%= school[i].names%></option>
                                <%}%>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>该教师可创建班级数</label>
                            <input type="number" min="1" class="form-control" id="teacher-reg-classnum" value="10">
                        </div>
                        <div class="form-group">
                            <label>每个班级可容纳的最大学生人数</label>
                            <input type="number" min="1" class="form-control" id="teacher-reg-stunum" value="35">
                        </div>
                        <%}else{%>
                        请先添加学校，<a href="/admin/schoollist" style="text-decoration: underline;">前往添加</a>
                        <%}%>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-success tch_changestu">确认</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    </div>
                </div>
            </div>
        </div>
        <!-- Javascripts -->
        <%include pub/admin_foot.html%>
        
        <%if(active == 'stulist'){%>
        <script type="text/javascript">
        $(function(){
            var countnums = $('#compagecount').val();
            var currentPage = parseInt($('#compageid').val());
            if(countnums >  29 ){
                var total = Math.ceil(countnums/30);
                var prev = currentPage -1;
                var next = currentPage +1;
                $.jqPaginator('#work-pagination', {
                    totalPages: total,
                    visiblePages:5,
                    currentPage:currentPage,
                    page: '<li class="page"><a href="/admin/stulist/{{page}}">{{page}}</a></li>',
                });
            }
        })
        </script>
        <%}else{%>
        <script type="text/javascript">
        $(function(){
            var countnums = $('#compagecount').val();
            var currentPage = parseInt($('#compageid').val());
            if(countnums >  29 ){
                var total = Math.ceil(countnums/30);
                var prev = currentPage -1;
                var next = currentPage +1;
                $.jqPaginator('#work-pagination', {
                    totalPages: total,
                    visiblePages:5,
                    currentPage:currentPage,
                    page: '<li class="page"><a href="/admin/stulist/vip/{{page}}">{{page}}</a></li>',
                });
            }
        })
        </script>
        <%}%>
    </body>
</html>